<?php
require_once '../config.php';
require_once '../dao/dao_login.php';
require_once '../dao/dao_db.php'; 
session_start();
function clear_session(){//quit system
//	unset($_SESSION['userid']);
//	unset($_SESSION['username']);
//	unset($_SESSION['password']);
//	unset($_SESSION['level']);
//	unset($_SESSION['list_theis']);
	session_destroy();
}
if(isset($_SESSION['userid'])){
	update_user_status($_SESSION['userid'],'',OFFLINE);
	mysql_close();
	clear_session();
	header("LOCATION:../index.php");
}else{
	header("LOCATION:../error.php?errcode=1");
}
?>